<?php

if(!defined('IN_NETGORESP')){ exit; }

//Template Class
class template
{
	function create_statbar($max_hp, $min_hp, $max_mp, $min_mp, $max_sp, $min_sp, $config){
		if($min_hp > $max_hp){ $max_hp = $min_hp; }
		if($min_mp > $max_mp){ $max_mp = $min_mp; }
		if($min_sp > $max_sp){ $max_sp = $min_sp; }
		$stathp = ceil($min_hp / $max_hp * 100); 
		$statsp = ceil($min_sp / $max_sp * 100);
		if ($min_mp != 0) { $statmp = ceil($min_mp / $max_mp * 100); } 
		else { $statmp = 0; }
		
		$stattable = "<label><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><tr><td align=\"left\"><table cellspacing=\"2\" cellpadding=\"0\" title=\"Hit Points: ".$min_hp." / ".$max_hp."\"><tr><td style=\"width: 25px; height:10px; font: 10px Verdana; vertical-align: middle;\">HP:</td><td style=\"padding:0px; width:100px; height:10px; border:solid 1px black; background-image:url(http://".$config['link']."/images/bars_grey.gif);\">\n";
	    	if ($stathp >= 66){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_green.gif);\"><img src=\"http://".$config['link']."/images/bars_green.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_greenend.gif\" alt=\"\" /></div>"; }
			if ($stathp < 66 && $stathp >= 33){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_yellow.gif);\"><img src=\"http://".$config['link']."/images/bars_yellow.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_yellowend.gif\" alt=\"\" /></div>"; }
			if ($stathp < 33 && $stathp >= 4){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"><img src=\"http://".$config['link']."/images/bars_red.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_redend.gif\" alt=\"\" /></div>"; }
			if ($stathp < 3){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$stathp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"><img src=\"http://".$config['link']."/images/bars_red.gif\" alt=\"\" /></div>"; }
		$stattable .="</td><td style=\"width: 60px; height:10px; font: 10px Verdana; vertical-align: middle;\">&nbsp;".$min_hp." / ".$max_hp."</td></tr></table></td></tr>";
		$stattable .= "<tr><td align=\"left\"><table cellspacing=\"2\" cellpadding=\"0\" title=\"Mana Points: ".$min_mp." / ".$max_mp."\"><tr><td style=\"width: 25px; height:10px; font: 10px Verdana; vertical-align: middle;\">MP:</td><td style=\"padding:0px; width:100px; height:10px; border:solid 1px black; background-image:url(http://".$config['link']."/images/bars_grey.gif);\">\n";
	        if ($statmp >= 66){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_green.gif);\"><img src=\"http://".$config['link']."/images/bars_green.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_greenend.gif\" alt=\"\" /></div>"; }
	        if ($statmp < 66 && $statmp >= 33){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_yellow.gif);\"><img src=\"http://".$config['link']."/images/bars_yellow.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_yellowend.gif\" alt=\"\" /></div>";}
			if ($statmp < 33 && $statmp >= 4){ $stattable .= "<div style=\" text-align:right; padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"><img src=\"http://".$config['link']."/images/bars_red.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_redend.gif\" alt=\"\" /></div>"; }
			if ($statmp < 3){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statmp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"></div>"; }
		$stattable .="</td><td style=\"width: 60px; height:10px; font: 10px Verdana; vertical-align: middle;\">&nbsp;".$min_mp." / ".$max_mp."</td></tr></table></td></tr>";
		$stattable .= "<tr><td align=\"left\"><table cellspacing=\"2\" cellpadding=\"0\" title=\"Stamina: ".$min_sp." / ".$max_sp."\"><tr><td style=\"width: 25px; height:10px; font: 10px Verdana; vertical-align: middle;\">SP:</td><td style=\"padding:0px; width:100px; height:10px; border:solid 1px black; background-image:url(http://".$config['link']."/images/bars_grey.gif);\">\n";
	        if ($statsp >= 66){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statsp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_green.gif);\"><img src=\"http://".$config['link']."/images/bars_green.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_greenend.gif\" alt=\"\" /></div>"; }
	        if ($statsp < 66 && $statsp >= 33){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statsp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_yellow.gif);\"><img src=\"http://".$config['link']."/images/bars_yellow.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_yellowend.gif\" alt=\"\" /></div>"; }
	        if ($statsp < 33 && $statsp >= 4){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statsp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"><img src=\"http://".$config['link']."/images/bars_red.gif\" alt=\"\" /><img src=\"http://".$config['link']."/images/bars_redend.gif\" alt=\"\" /></div>"; }
			if ($statsp < 3){ $stattable .= "<div style=\"text-align:right; padding:0px; width:".$statsp."px; border-top:solid 0px black; background-image:url(http://".$config['link']."/images/bars_red.gif);\"><img src=\"http://".$config['link']."/images/bars_red.gif\" alt=\"\" /></div>"; }
		$stattable .="</td><td style=\"width: 60px; height:10px; font: 10px Verdana; vertical-align: middle;\">&nbsp;".$min_sp." / ".$max_sp."</td></tr></table></td></tr></table></label>";	
		$finalizetable = $stattable;
		
	return $finalizetable;
	}
	
	/*
	-------------------------------------------------------------
	Create Navigation
	-------------------------------------------------------------
	@param	string	$userrow		Contains user information, if there is any.
	@param	array		$links		Contains the Links that will be shown in the navigation
	@param	int		$online		Number of users online.
	@return	mixed				When parsed, it checks whether the user is logged in, If not sends guest navigation. If it was it sends the users navigation.
	-------------------------------------------------------------
	*/
	function create_nav($userinfo,$links,$online,$lang)
	{
		$this->userinfo = $userinfo;
		$this->link = $links;
		$this->online = $online;
		
			if ($this->userinfo == false) 
			{ 
			    $this->username = $lang['guest'];
				$this->navigation = 'Welcome '.$this->username.'&nbsp;&bull;&nbsp;
					<a href="'.$this->link['login'].'">'.$lang['login'].'</a>&nbsp;&bull;&nbsp;				
					<a href="'.$this->link['register'].'">'.$lang['rPage'].'</a>&nbsp;&bull;&nbsp;
					<a href="'.$this->link['users'].'">'.$lang['uPage'].'</a>&nbsp;&bull;&nbsp;
					<a href="'.$this->link['online'].'">'.$lang['uOnline'].': '.$this->online.'</a>';
			} 
			else 
			{
				$this->username = $this->userinfo["name"];
				$this->navigation = 'Welcome '.$this->username.'&nbsp;&bull;&nbsp;
					<a href="'.$this->link['main'].'">'.$lang['pPage'].'</a>&nbsp;&bull;&nbsp;
					<a href="'.$this->link['users'].'">'.$lang['uPage'].'</a>&nbsp;&bull;&nbsp;
					<a href="'.$this->link['logout'].'">'.$lang['logout'].'</a>&nbsp;&bull;&nbsp;
					<a href="'.$this->link['online'].'">'.$lang['uOnline'].': '.$this->online.'</a>';
			}
			
		return $this->navigation;
	}
	
	/*
	-------------------------------------------------------------
	Error Template
	-------------------------------------------------------------
	@param	string	$title 		Contains the Error Condensed into a title
	@param	string	$reason		Contains the Base Error
	-------------------------------------------------------------
	*/
	function error($title,$reason)
	{
		if($title != "Login Error"){
			$note = '<font style="color:#990000;">*Note:</font> If you cannot figure out how to get rid of this message or do not understand the error, please message Skye <a href="http://www.netgore.com/">Here</a>. Thank you very much.';
		}
		
		return '<html>
					<head>
						<title>NetgoreSP - '.$title.'</title>
						<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
						<link rel="stylesheet" type="text/css" href="template/vbgoresp/css/template_error.css" />
					</head>
					<body>
						<div id="container">
							<h1 style="border-bottom: 1px solid #ddd; margin-bottom: 4px;">Netgore<span style="color:limegreen">SP</span> &rarr; '.$title.'</h1><br />
							<div class="error">'.$reason.'</div><br />
							<div class="note">'.$note.'</div>
					</body>
				</html>';
	}

}

?>